package com.complex.spring.mvc.controller;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.complex.spring.mvc.service.LoginService;
/**
 * 基于注解的controller
 * @author gao
 *
 */
@Controller
@RequestMapping("/login.controller")//映射关系(发布的handlerMapping)
public class LoginAnnoController{
	
	static final Log logger = LogFactory.getLog(LoginAnnoController.class);
	
	@Autowired
	LoginService loginService;

	//处理@RequestMapping 定义了的方法,后面为请求类型
	@RequestMapping(method={RequestMethod.GET,RequestMethod.POST})
	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		//输出log信息
		if(logger.isInfoEnabled()){
			logger.info("=======================LoginAnnoController handleRequest=======================");
		}
		//处理业务逻辑
		//loginService.doLogin();
		
		//设置返回数据
		HashMap<String,String> param = new HashMap<String,String>();
		param.put("loginId", "ymkyve");
		param.put("annotation", "annotation");
		
		//返回到login.jsp
		return new ModelAndView("jsp/login.jsp",param);
	}

	
}
